
import request from '@/utils/request'
import {apiUrl} from '@/utils/env'
var qs = require('qs');
const baseUrl = apiUrl.base
//登录
export function login(data) {
  return request({
    baseURL: baseUrl,
    url: '/login',
    headers:{
      'Content-type': 'application/x-www-form-urlencoded'
     },
    method: 'post',
    data:qs.stringify({...data})
  })
}
export function register(data) {
  return request({
    baseURL: baseUrl,
    url: '/guest/register',
    method: 'post',
    data
  })
}
//查询用户信息
export function getUserInfo(args) {
  return request({
    baseURL: baseUrl,
    url: '/user/user/'+args,
    method: 'get',
  })
}
//添加/编辑用户信息
export function userInfo(data,param) {
  return request({
    baseURL: baseUrl,
    url:Boolean(param)?"/user/user/"+param:'/user/user',
    method: 'post',
    data
  })
}

//用户列表
export function userList(args) {
  return request({
    baseURL: baseUrl,
    url: '/user/user',
    method: 'get',
    params: args
  })
}

 //添加充值卡
export function cardInfo(data) {
  return request({
    baseURL: baseUrl,
    url:'/user/prepaid',
    method: 'post',
    data
  })
}

//充值卡列表
export function cardList(args,param) {
  return request({
    baseURL: baseUrl,
    url:Boolean(param)?'/user/prepaid/'+param:'/user/prepaid',
    method: 'get',
    params: args
  })
}
//充值
export function recharge(data,param) {
  return request({
    baseURL: baseUrl,
    url:Boolean(param)?"/user/prepaid/active/"+param:'/user/prepaid/active/',
    method: 'post',
    data
  })
}

//查询服务信息
export function getServiceInfo(args) {
  return request({
    baseURL: baseUrl,
    url: '/user/store',
    method: 'get',
    params: args
  })
}
//添加服务信息
export function addServiceInfo(args) {
  return request({
    baseURL: baseUrl,
    url: '/user/store',
    method: 'post',
    params: args
  })
}
//服务列表
export function serviceList(args) {
  return request({
    baseURL: baseUrl,
    url: '/user/store',
    method: 'get',
    params: args
  })
}


export function getArticleInfo(id) {
  return request({
    baseURL: baseUrl,
    url: '/user/article/'+id,
    method: 'get',
  })
}
//添加/编辑文章
export function articleInfo(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/article',
    method: 'post',
    data
  })
}
//服务列表
export function articleList(args) {
  return request({
    baseURL: baseUrl,
    url: '/user/article',
    method: 'get',
    params: args
  })
}
export function homeNews(args) {
  return request({
    baseURL: baseUrl,
    url: '/guest/article',
    method: 'get',
    params: args
  })
}
//注销
export function logout() {
  return request({
    baseURL: baseUrl,
    url: '/signout',
    method: 'post'
  })
}
//密码找回
export function findpwd(data) {
  return request({
    baseURL: baseUrl,
    url: '/guest/findout/password',
    method: 'post',
    data
  })
}

//最近十笔买卖
export function trade(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/bill',
    method: 'get',
    params: data,
  })
}
//交易价格
export function price(date) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/price',
    method: 'get',
    params:date,
  })
}
//交易量
export function amount(date) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/volume',
    method: 'get',
    params:date,
  })
}
//交易信息列表
export function tradeInfo() {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/info',
    method: 'get'
  })
}

//交易价格
export function k_price(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/kline/price',
    method: 'get',
    params:data,
  })
}
//交易量
export function k_amount(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/kline/volume',
    method: 'get',
    params:data,
  })
}
//当前交易信息
export function currentTrade() {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/info/current',
    method: 'get'
  })
}
export function batchScore(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/user/points/batch',
    method: 'post',
    data
  })
}
export function batchTime(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/user/vipTime/batch',
    method: 'post',
    data
  })
}
//获取手机验证码
export function getMobileCode(data) {
  return request({
    baseURL: baseUrl,
    url: '/guest/validationCode',
    method: 'post',
    data
  })
}
//获取手机验证码
export function getAccessCount(data) {
  return request({
    baseURL: baseUrl,
    url: '/guest/accessCount',
    method: 'get',
    params:data,
  })
}
//签到规则
export function checkRules() {
  return request({
    baseURL: baseUrl,
    url: '/user/checkInRecord/rules',
    method: 'get',
  })
}
//查询签到数据
export function checkData() {
  return request({
    baseURL: baseUrl,
    url: '/user/checkInRecord/latest',
    method: 'get',
  })
}
//签到
export function checked_click() {
  return request({
    baseURL: baseUrl,
    url: '/user/checkInRecord',
    method: 'post',
  })
}
//积分兑换

export function exchange(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/exchange',
    method: 'post',
    data,
  })
}
export function getScore(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/userscore/me',
    method: 'get',
     params:data,
  })
}

//广告宝
export function getAdvertisement(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/adBao',
    method: 'get',
     params:data,
  })
}
//管理端广告宝列表
export function getAdvertisementPageList(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/adBao/page',
    method: 'get',
     params:data,
  })
}
//删除广告宝
export function delAdvertisement(id) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/adBao/'+id,
    method: 'DELETE',
  })
}

//新增广告宝
export function saveAdvertisement(data) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/adBao',
    method: 'POST',
    data
  })
}
export function getAdvertisementById(id) {
  return request({
    baseURL: baseUrl,
    url: '/user/trade/adBao/'+id,
    method: 'GET',
  })
}
// 不用登录的广告包查询
export function getAdvertisementIndex() {
  return request({
    baseURL: baseUrl,
    url: '/guest/trade/adBao/',
    method: 'GET',
  })
}